import { Controller, Post, Body } from '@nestjs/common';
import { DictitemService } from './dictitem.service';
import { CreateDictitemDto, FindDictitemDto, UpdateDictitemDto, RemoveDictitemDto, CreateBatchDictitemDto, RemoveBatchDictitemDto } from './dto/dictitem.dto';
import { Authority } from '@/common/decorators/authority.decorator';
import { useResult } from '@/common/hooks/useResult';

@Controller('dictitem')
export class DictitemController {
  constructor(private readonly dictitemService: DictitemService) {}

  @Post('create')
  @Authority('dictitem:create')
  async create(@Body() body: CreateDictitemDto) {
    const res = await this.dictitemService.create(body);
    return useResult(res);
  }

  @Post('findAll')
  @Authority('dictitem:find')
  async findAll(@Body() body: FindDictitemDto) {
    const res = await this.dictitemService.findAll(body);
    return useResult(res);
  }

  @Post('findOne')
  @Authority('dictitem:find')
  async findOne(@Body() body: FindDictitemDto) {
    const res = await this.dictitemService.findOne(body);
    return useResult(res);
  }

  @Post('update')
  @Authority('dictitem:update')
  async update(@Body() body: UpdateDictitemDto) {
    const res = await this.dictitemService.update(body);
    return useResult(res);
  }

  @Post('remove')
  @Authority('dictitem:remove')
  async remove(@Body() body: RemoveDictitemDto) {
    const res = await this.dictitemService.remove(body);
    return useResult(res);
  }

  @Post('removeBatch')
  @Authority('dictitem:remove')
  async removeBatch(@Body() body: RemoveBatchDictitemDto) {
    const res = await this.dictitemService.removeBatch(body);
    return useResult(res);
  }

  @Post('createBatch')
  @Authority('dictitem:create')
  async createBatch(@Body() body: CreateBatchDictitemDto) {
    const res = await this.dictitemService.createBatch(body);
    return useResult(res);
  }
}
